home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 941 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.5 KB

  1. From: Philippe Verdy <100105.3120@compuserve.com>
  2. Message-ID: <4jsf81$t2m@dub-news-svc-3.compuserve.com>
  3. X-Original-Date: 3 Apr 1996 00:03:04 GMT
  4. Path: in2.uu.net!bounce-back
  5. Date: 03 Apr 96 03:10:47 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: static members as members of a metaclass h
  9. Organization: CompuServe Incorporated
  10. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  11.     iQBFAgUBMWHsW+EDnX0m9pzZAQGX4QF/RoYSA2z9/X0+VPtKThGwCefFuuSwqG61
  12.     SYdFugTce9PRPLGCpIieglHTcp1m6kxV
  13.     =4ejg
  14.  
  15. kanze@gabi-soft.fr (J. Kanze) s'icrit :
  16. > In article <4jckdc$ad6@engnews1.Eng.Sun.COM> clamage@Eng.Sun.COM (Steve
  17. > Clamage) writes:
  18. >     [...]
  19. > |> I believe a reasonable solution to the problem of initialization of
  20. > |> non-local static data is not to use non-local static data!
  21. > |> Instead of a static data object or static class data member, use a 
  22. > |> function with a local static object.
  23. >     [...]
  24. > |> Only two features are missing, compared to non-local static objects:
  25. > |> 1. If you never reference an object, it is never initialized.
  26. > But is this guaranteed by the standard anyway?  I know that I have a
  27. > significant number of static objects which must be initialized before
  28. > main (but in any order), but I have always believed that this works
  29. > because of the way current compilers work, and not because of anything
  30. > in the standard.
  31. > |> 2. The order of destruction remains unspecified. If that is a problem,
  32. > |> possibly the static objects could be of a type which has a do-nothing
  33. > |> destructor and a "destroy" member function which could be called
  34. > |> explicitly at the proper time.
  35. > I thought that the order of destruction was the reverse of
  36. > initialization.  This is what it says in the January draft, at least.
  37. > Has this been changed?
  38.  
  39. I think that the order of destruction of static objects is
  40. unspecified, only because the order of construction is unspe-
  41. cified.
  42.  
  43. Which ever order the compiler chooses, the order of destruction
  44. of the same static objects MUST be the exact opposite of their
  45. construction order ! This is compiler-dependent.
  46.  
  47. I suggest the standard allows for static class constructors to
  48. remove this compiler dependence !
  49. ---
  50. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  51. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  52. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  53. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  54. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  55.